\documentclass[11pt]{article}

    \usepackage[breakable]{tcolorbox}
    \usepackage{parskip} % Stop auto-indenting (to mimic markdown behaviour)
    
    \usepackage{iftex}
    \ifPDFTeX
    	\usepackage[T1]{fontenc}
    	\usepackage{mathpazo}
    \else
    	\usepackage{fontspec}
    \fi

    % Basic figure setup, for now with no caption control since it's done
    % automatically by Pandoc (which extracts ![](path) syntax from Markdown).
    \usepackage{graphicx}
    % Maintain compatibility with old templates. Remove in nbconvert 6.0
    \let\Oldincludegraphics\includegraphics
    % Ensure that by default, figures have no caption (until we provide a
    % proper Figure object with a Caption API and a way to capture that
    % in the conversion process - todo).
    \usepackage{caption}
    \DeclareCaptionFormat{nocaption}{}
    \captionsetup{format=nocaption,aboveskip=0pt,belowskip=0pt}

    \usepackage{float}
    \floatplacement{figure}{H} % forces figures to be placed at the correct location
    \usepackage{xcolor} % Allow colors to be defined
    \usepackage{enumerate} % Needed for markdown enumerations to work
    \usepackage{geometry} % Used to adjust the document margins
    \usepackage{amsmath} % Equations
    \usepackage{amssymb} % Equations
    \usepackage{textcomp} % defines textquotesingle
    % Hack from http://tex.stackexchange.com/a/47451/13684:
    \AtBeginDocument{%
        \def\PYZsq{\textquotesingle}% Upright quotes in Pygmentized code
    }
    \usepackage{upquote} % Upright quotes for verbatim code
    \usepackage{eurosym} % defines \euro
    \usepackage[mathletters]{ucs} % Extended unicode (utf-8) support
    \usepackage{fancyvrb} % verbatim replacement that allows latex
    \usepackage{grffile} % extends the file name processing of package graphics 
                         % to support a larger range
    \makeatletter % fix for old versions of grffile with XeLaTeX
    \@ifpackagelater{grffile}{2019/11/01}
    {
      % Do nothing on new versions
    }
    {
      \def\Gread@@xetex#1{%
        \IfFileExists{"\Gin@base".bb}%
        {\Gread@eps{\Gin@base.bb}}%
        {\Gread@@xetex@aux#1}%
      }
    }
    \makeatother
    \usepackage[Export]{adjustbox} % Used to constrain images to a maximum size
    \adjustboxset{max size={0.9\linewidth}{0.9\paperheight}}

    % The hyperref package gives us a pdf with properly built
    % internal navigation ('pdf bookmarks' for the table of contents,
    % internal cross-reference links, web links for URLs, etc.)
    \usepackage{hyperref}
    % The default LaTeX title has an obnoxious amount of whitespace. By default,
    % titling removes some of it. It also provides customization options.
    \usepackage{titling}
    \usepackage{longtable} % longtable support required by pandoc >1.10
    \usepackage{booktabs}  % table support for pandoc > 1.12.2
    \usepackage[inline]{enumitem} % IRkernel/repr support (it uses the enumerate* environment)
    \usepackage[normalem]{ulem} % ulem is needed to support strikethroughs (\sout)
                                % normalem makes italics be italics, not underlines
    \usepackage{mathrsfs}
    

    
    % Colors for the hyperref package
    \definecolor{urlcolor}{rgb}{0,.145,.698}
    \definecolor{linkcolor}{rgb}{.71,0.21,0.01}
    \definecolor{citecolor}{rgb}{.12,.54,.11}

    % ANSI colors
    \definecolor{ansi-black}{HTML}{3E424D}
    \definecolor{ansi-black-intense}{HTML}{282C36}
    \definecolor{ansi-red}{HTML}{E75C58}
    \definecolor{ansi-red-intense}{HTML}{B22B31}
    \definecolor{ansi-green}{HTML}{00A250}
    \definecolor{ansi-green-intense}{HTML}{007427}
    \definecolor{ansi-yellow}{HTML}{DDB62B}
    \definecolor{ansi-yellow-intense}{HTML}{B27D12}
    \definecolor{ansi-blue}{HTML}{208FFB}
    \definecolor{ansi-blue-intense}{HTML}{0065CA}
    \definecolor{ansi-magenta}{HTML}{D160C4}
    \definecolor{ansi-magenta-intense}{HTML}{A03196}
    \definecolor{ansi-cyan}{HTML}{60C6C8}
    \definecolor{ansi-cyan-intense}{HTML}{258F8F}
    \definecolor{ansi-white}{HTML}{C5C1B4}
    \definecolor{ansi-white-intense}{HTML}{A1A6B2}
    \definecolor{ansi-default-inverse-fg}{HTML}{FFFFFF}
    \definecolor{ansi-default-inverse-bg}{HTML}{000000}

    % common color for the border for error outputs.
    \definecolor{outerrorbackground}{HTML}{FFDFDF}

    % commands and environments needed by pandoc snippets
    % extracted from the output of `pandoc -s`
    \providecommand{\tightlist}{%
      \setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}}
    \DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}}
    % Add ',fontsize=\small' for more characters per line
    \newenvironment{Shaded}{}{}
    \newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
    \newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}}
    \newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
    \newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
    \newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}}
    \newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}}
    \newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}}
    \newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
    \newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}}
    \newcommand{\RegionMarkerTok}[1]{{#1}}
    \newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}}
    \newcommand{\NormalTok}[1]{{#1}}
    
    % Additional commands for more recent versions of Pandoc
    \newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{{#1}}}
    \newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}}
    \newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{{#1}}}
    \newcommand{\ImportTok}[1]{{#1}}
    \newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{{#1}}}}
    \newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    \newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    \newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{{#1}}}
    \newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}}
    \newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{{#1}}}
    \newcommand{\BuiltInTok}[1]{{#1}}
    \newcommand{\ExtensionTok}[1]{{#1}}
    \newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{{#1}}}
    \newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{{#1}}}
    \newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    \newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}}
    
    
    % Define a nice break command that doesn't care if a line doesn't already
    % exist.
    \def\br{\hspace*{\fill} \\* }
    % Math Jax compatibility definitions
    \def\gt{>}
    \def\lt{<}
    \let\Oldtex\TeX
    \let\Oldlatex\LaTeX
    \renewcommand{\TeX}{\textrm{\Oldtex}}
    \renewcommand{\LaTeX}{\textrm{\Oldlatex}}
    % Document parameters
    % Document title
    \title{ex\_3\_5}
    
    
    
    
    
% Pygments definitions
\makeatletter
\def\PY@reset{\let\PY@it=\relax \let\PY@bf=\relax%
    \let\PY@ul=\relax \let\PY@tc=\relax%
    \let\PY@bc=\relax \let\PY@ff=\relax}
\def\PY@tok#1{\csname PY@tok@#1\endcsname}
\def\PY@toks#1+{\ifx\relax#1\empty\else%
    \PY@tok{#1}\expandafter\PY@toks\fi}
\def\PY@do#1{\PY@bc{\PY@tc{\PY@ul{%
    \PY@it{\PY@bf{\PY@ff{#1}}}}}}}
\def\PY#1#2{\PY@reset\PY@toks#1+\relax+\PY@do{#2}}

\@namedef{PY@tok@w}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.73,0.73}{##1}}}
\@namedef{PY@tok@c}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@cp}{\def\PY@tc##1{\textcolor[rgb]{0.74,0.48,0.00}{##1}}}
\@namedef{PY@tok@k}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kp}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kt}{\def\PY@tc##1{\textcolor[rgb]{0.69,0.00,0.25}{##1}}}
\@namedef{PY@tok@o}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@ow}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\@namedef{PY@tok@nb}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@nf}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@nc}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@nn}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@ne}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.82,0.25,0.23}{##1}}}
\@namedef{PY@tok@nv}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@no}{\def\PY@tc##1{\textcolor[rgb]{0.53,0.00,0.00}{##1}}}
\@namedef{PY@tok@nl}{\def\PY@tc##1{\textcolor[rgb]{0.63,0.63,0.00}{##1}}}
\@namedef{PY@tok@ni}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.60,0.60,0.60}{##1}}}
\@namedef{PY@tok@na}{\def\PY@tc##1{\textcolor[rgb]{0.49,0.56,0.16}{##1}}}
\@namedef{PY@tok@nt}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@nd}{\def\PY@tc##1{\textcolor[rgb]{0.67,0.13,1.00}{##1}}}
\@namedef{PY@tok@s}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sd}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@si}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}}
\@namedef{PY@tok@se}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.13}{##1}}}
\@namedef{PY@tok@sr}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.40,0.53}{##1}}}
\@namedef{PY@tok@ss}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@sx}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@m}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@gh}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\@namedef{PY@tok@gu}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.50,0.00,0.50}{##1}}}
\@namedef{PY@tok@gd}{\def\PY@tc##1{\textcolor[rgb]{0.63,0.00,0.00}{##1}}}
\@namedef{PY@tok@gi}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.63,0.00}{##1}}}
\@namedef{PY@tok@gr}{\def\PY@tc##1{\textcolor[rgb]{1.00,0.00,0.00}{##1}}}
\@namedef{PY@tok@ge}{\let\PY@it=\textit}
\@namedef{PY@tok@gs}{\let\PY@bf=\textbf}
\@namedef{PY@tok@gp}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,0.50}{##1}}}
\@namedef{PY@tok@go}{\def\PY@tc##1{\textcolor[rgb]{0.53,0.53,0.53}{##1}}}
\@namedef{PY@tok@gt}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.27,0.87}{##1}}}
\@namedef{PY@tok@err}{\def\PY@bc##1{{\setlength{\fboxsep}{-\fboxrule}\fcolorbox[rgb]{1.00,0.00,0.00}{1,1,1}{\strut ##1}}}}
\@namedef{PY@tok@kc}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kd}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kn}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@kr}{\let\PY@bf=\textbf\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@bp}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.50,0.00}{##1}}}
\@namedef{PY@tok@fm}{\def\PY@tc##1{\textcolor[rgb]{0.00,0.00,1.00}{##1}}}
\@namedef{PY@tok@vc}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vg}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vi}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@vm}{\def\PY@tc##1{\textcolor[rgb]{0.10,0.09,0.49}{##1}}}
\@namedef{PY@tok@sa}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sb}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sc}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@dl}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@s2}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@sh}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@s1}{\def\PY@tc##1{\textcolor[rgb]{0.73,0.13,0.13}{##1}}}
\@namedef{PY@tok@mb}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mf}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mh}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mi}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@il}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@mo}{\def\PY@tc##1{\textcolor[rgb]{0.40,0.40,0.40}{##1}}}
\@namedef{PY@tok@ch}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@cm}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@cpf}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@c1}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}
\@namedef{PY@tok@cs}{\let\PY@it=\textit\def\PY@tc##1{\textcolor[rgb]{0.25,0.50,0.50}{##1}}}

\def\PYZbs{\char`\\}
\def\PYZus{\char`\_}
\def\PYZob{\char`\{}
\def\PYZcb{\char`\}}
\def\PYZca{\char`\^}
\def\PYZam{\char`\&}
\def\PYZlt{\char`\<}
\def\PYZgt{\char`\>}
\def\PYZsh{\char`\#}
\def\PYZpc{\char`\%}
\def\PYZdl{\char`\$}
\def\PYZhy{\char`\-}
\def\PYZsq{\char`\'}
\def\PYZdq{\char`\"}
\def\PYZti{\char`\~}
% for compatibility with earlier versions
\def\PYZat{@}
\def\PYZlb{[}
\def\PYZrb{]}
\makeatother


    % For linebreaks inside Verbatim environment from package fancyvrb. 
    \makeatletter
        \newbox\Wrappedcontinuationbox 
        \newbox\Wrappedvisiblespacebox 
        \newcommand*\Wrappedvisiblespace {\textcolor{red}{\textvisiblespace}} 
        \newcommand*\Wrappedcontinuationsymbol {\textcolor{red}{\llap{\tiny$\m@th\hookrightarrow$}}} 
        \newcommand*\Wrappedcontinuationindent {3ex } 
        \newcommand*\Wrappedafterbreak {\kern\Wrappedcontinuationindent\copy\Wrappedcontinuationbox} 
        % Take advantage of the already applied Pygments mark-up to insert 
        % potential linebreaks for TeX processing. 
        %        {, <, #, %, $, ' and ": go to next line. 
        %        _, }, ^, &, >, - and ~: stay at end of broken line. 
        % Use of \textquotesingle for straight quote. 
        \newcommand*\Wrappedbreaksatspecials {% 
            \def\PYGZus{\discretionary{\char`\_}{\Wrappedafterbreak}{\char`\_}}% 
            \def\PYGZob{\discretionary{}{\Wrappedafterbreak\char`\{}{\char`\{}}% 
            \def\PYGZcb{\discretionary{\char`\}}{\Wrappedafterbreak}{\char`\}}}% 
            \def\PYGZca{\discretionary{\char`\^}{\Wrappedafterbreak}{\char`\^}}% 
            \def\PYGZam{\discretionary{\char`\&}{\Wrappedafterbreak}{\char`\&}}% 
            \def\PYGZlt{\discretionary{}{\Wrappedafterbreak\char`\<}{\char`\<}}% 
            \def\PYGZgt{\discretionary{\char`\>}{\Wrappedafterbreak}{\char`\>}}% 
            \def\PYGZsh{\discretionary{}{\Wrappedafterbreak\char`\#}{\char`\#}}% 
            \def\PYGZpc{\discretionary{}{\Wrappedafterbreak\char`\%}{\char`\%}}% 
            \def\PYGZdl{\discretionary{}{\Wrappedafterbreak\char`\$}{\char`\$}}% 
            \def\PYGZhy{\discretionary{\char`\-}{\Wrappedafterbreak}{\char`\-}}% 
            \def\PYGZsq{\discretionary{}{\Wrappedafterbreak\textquotesingle}{\textquotesingle}}% 
            \def\PYGZdq{\discretionary{}{\Wrappedafterbreak\char`\"}{\char`\"}}% 
            \def\PYGZti{\discretionary{\char`\~}{\Wrappedafterbreak}{\char`\~}}% 
        } 
        % Some characters . , ; ? ! / are not pygmentized. 
        % This macro makes them "active" and they will insert potential linebreaks 
        \newcommand*\Wrappedbreaksatpunct {% 
            \lccode`\~`\.\lowercase{\def~}{\discretionary{\hbox{\char`\.}}{\Wrappedafterbreak}{\hbox{\char`\.}}}% 
            \lccode`\~`\,\lowercase{\def~}{\discretionary{\hbox{\char`\,}}{\Wrappedafterbreak}{\hbox{\char`\,}}}% 
            \lccode`\~`\;\lowercase{\def~}{\discretionary{\hbox{\char`\;}}{\Wrappedafterbreak}{\hbox{\char`\;}}}% 
            \lccode`\~`\:\lowercase{\def~}{\discretionary{\hbox{\char`\:}}{\Wrappedafterbreak}{\hbox{\char`\:}}}% 
            \lccode`\~`\?\lowercase{\def~}{\discretionary{\hbox{\char`\?}}{\Wrappedafterbreak}{\hbox{\char`\?}}}% 
            \lccode`\~`\!\lowercase{\def~}{\discretionary{\hbox{\char`\!}}{\Wrappedafterbreak}{\hbox{\char`\!}}}% 
            \lccode`\~`\/\lowercase{\def~}{\discretionary{\hbox{\char`\/}}{\Wrappedafterbreak}{\hbox{\char`\/}}}% 
            \catcode`\.\active
            \catcode`\,\active 
            \catcode`\;\active
            \catcode`\:\active
            \catcode`\?\active
            \catcode`\!\active
            \catcode`\/\active 
            \lccode`\~`\~ 	
        }
    \makeatother

    \let\OriginalVerbatim=\Verbatim
    \makeatletter
    \renewcommand{\Verbatim}[1][1]{%
        %\parskip\z@skip
        \sbox\Wrappedcontinuationbox {\Wrappedcontinuationsymbol}%
        \sbox\Wrappedvisiblespacebox {\FV@SetupFont\Wrappedvisiblespace}%
        \def\FancyVerbFormatLine ##1{\hsize\linewidth
            \vtop{\raggedright\hyphenpenalty\z@\exhyphenpenalty\z@
                \doublehyphendemerits\z@\finalhyphendemerits\z@
                \strut ##1\strut}%
        }%
        % If the linebreak is at a space, the latter will be displayed as visible
        % space at end of first line, and a continuation symbol starts next line.
        % Stretch/shrink are however usually zero for typewriter font.
        \def\FV@Space {%
            \nobreak\hskip\z@ plus\fontdimen3\font minus\fontdimen4\font
            \discretionary{\copy\Wrappedvisiblespacebox}{\Wrappedafterbreak}
            {\kern\fontdimen2\font}%
        }%
        
        % Allow breaks at special characters using \PYG... macros.
        \Wrappedbreaksatspecials
        % Breaks at punctuation characters . , ; ? ! and / need catcode=\active 	
        \OriginalVerbatim[#1,codes*=\Wrappedbreaksatpunct]%
    }
    \makeatother

    % Exact colors from NB
    \definecolor{incolor}{HTML}{303F9F}
    \definecolor{outcolor}{HTML}{D84315}
    \definecolor{cellborder}{HTML}{CFCFCF}
    \definecolor{cellbackground}{HTML}{F7F7F7}
    
    % prompt
    \makeatletter
    \newcommand{\boxspacing}{\kern\kvtcb@left@rule\kern\kvtcb@boxsep}
    \makeatother
    \newcommand{\prompt}[4]{
        {\ttfamily\llap{{\color{#2}[#3]:\hspace{3pt}#4}}\vspace{-\baselineskip}}
    }
    

    
    % Prevent overflowing lines due to hard-to-break entities
    \sloppy 
    % Setup hyperref package
    \hypersetup{
      breaklinks=true,  % so long urls are correctly broken across lines
      colorlinks=true,
      urlcolor=urlcolor,
      linkcolor=linkcolor,
      citecolor=citecolor,
      }
    % Slightly bigger margins than the latex defaults
    
    \geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in}
    
    

\begin{document}
    
    \maketitle
    
    

    
    \hypertarget{ux4e60ux9898-3.5}{%
\subsection{习题 3.5}\label{ux4e60ux9898-3.5}}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{1}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{raw\PYZus{}data} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n+nf}{read.csv}\PY{p}{(}\PY{l+s}{\PYZdq{}}\PY{l+s}{./ex\PYZus{}3\PYZus{}5.csv\PYZdq{}}\PY{p}{)}
\PY{n}{raw\PYZus{}data}
\end{Verbatim}
\end{tcolorbox}

    A data.frame: 3 × 13
\begin{tabular}{lllllllllllll}
 科研经费投入 & 生产能力提高量 & 生产能力提高量.1 & 生产能力提高量.2 & 生产能力提高量.3 & 生产能力提高量.4 & 生产能力提高量.5 & 生产能力提高量.6 & 生产能力提高量.7 & 生产能力提高量.8 & 生产能力提高量.9 & 生产能力提高量.10 & 生产能力提高量.11\\
 <chr> & <dbl> & <dbl> & <dbl> & <dbl> & <dbl> & <dbl> & <chr> & <chr> & <chr> & <chr> & <chr> & <dbl>\\
\hline
	 低 & 7.6 & 8.2 &  6.8 & 5.8 & 6.9 & 6.6 & 6.3 & 7.7 & 6   &     &     &  NA\\
	 中 & 6.7 & 8.1 &  9.4 & 8.6 & 7.8 & 7.7 & 8.9 & 7.9 & 8.3 & 8.7 & 7.1 & 8.4\\
	 高 & 8.5 & 9.7 & 10.1 & 7.8 & 9.6 & 9.5 &     &     &     &     &     &  NA\\
\end{tabular}


    
    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{2}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{t\PYZus{}raw\PYZus{}data} \PY{o}{=} \PY{n+nf}{t}\PY{p}{(}\PY{n}{raw\PYZus{}data}\PY{p}{)}  \PY{c+c1}{\PYZsh{} 转置，方便取数据}

\PY{n}{dict} \PY{o}{=} \PY{n+nf}{c}\PY{p}{(}\PY{l+s}{\PYZdq{}}\PY{l+s}{low\PYZdq{}}\PY{p}{,} \PY{l+s}{\PYZdq{}}\PY{l+s}{mid\PYZdq{}}\PY{p}{,} \PY{l+s}{\PYZdq{}}\PY{l+s}{high\PYZdq{}}\PY{p}{)}
\PY{n+nf}{names}\PY{p}{(}\PY{n}{dict}\PY{p}{)} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n+nf}{c}\PY{p}{(}\PY{l+s}{\PYZdq{}}\PY{l+s}{低\PYZdq{}}\PY{p}{,} \PY{l+s}{\PYZdq{}}\PY{l+s}{中\PYZdq{}}\PY{p}{,} \PY{l+s}{\PYZdq{}}\PY{l+s}{高\PYZdq{}}\PY{p}{)}

\PY{n}{investment} \PY{o}{=} \PY{n+nf}{c}\PY{p}{(}\PY{p}{)}   \PY{c+c1}{\PYZsh{} 科研经费投入}
\PY{n}{improvement} \PY{o}{=} \PY{n+nf}{c}\PY{p}{(}\PY{p}{)}  \PY{c+c1}{\PYZsh{} 生产能力提高量}

\PY{n+nf}{for }\PY{p}{(}\PY{n}{i} \PY{n}{in} \PY{l+m}{1}\PY{o}{:}\PY{l+m}{3}\PY{p}{)} \PY{p}{\PYZob{}}
    \PY{n}{b} \PY{o}{=} \PY{n}{dict}\PY{p}{[[}\PY{n}{t\PYZus{}raw\PYZus{}data}\PY{p}{[[}\PY{l+m}{1}\PY{p}{,}\PY{n}{i}\PY{p}{]]}\PY{p}{]]}   \PY{c+c1}{\PYZsh{} 科研经费投入}
    
    \PY{n}{a} \PY{o}{=} \PY{n+nf}{array}\PY{p}{(}\PY{n}{t\PYZus{}raw\PYZus{}data}\PY{p}{[}\PY{l+m}{\PYZhy{}1}\PY{p}{,}\PY{n}{i}\PY{p}{]}\PY{p}{)}   \PY{c+c1}{\PYZsh{} 生产能力提高量：下面 2 行将数据转化为 dobule 型，并清除 NA、空值}
    \PY{n}{a} \PY{o}{=} \PY{n+nf}{apply}\PY{p}{(}\PY{n}{a}\PY{p}{[}\PY{o}{!}\PY{n+nf}{is.na}\PY{p}{(}\PY{n}{a}\PY{p}{)}\PY{p}{]}\PY{p}{,} \PY{l+m}{1}\PY{p}{,} \PY{n}{as.double}\PY{p}{)}  \PY{c+c1}{\PYZsh{} 这里会有一些产生 NA 的 Warning，这个问题来自：as.double(\PYZdq{}\PYZdq{})，不必在意}
    \PY{n}{a} \PY{o}{=} \PY{n}{a}\PY{p}{[}\PY{o}{!}\PY{n+nf}{is.na}\PY{p}{(}\PY{n}{a}\PY{p}{)}\PY{p}{]}  
    
    \PY{n+nf}{for }\PY{p}{(}\PY{n}{p} \PY{n}{in} \PY{n}{a}\PY{p}{)} \PY{p}{\PYZob{}}
        \PY{n}{investment} \PY{o}{=} \PY{n+nf}{c}\PY{p}{(}\PY{n}{investment}\PY{p}{,} \PY{n}{b}\PY{p}{)}
        \PY{n}{improvement} \PY{o}{=} \PY{n+nf}{c}\PY{p}{(}\PY{n}{improvement}\PY{p}{,} \PY{n}{p}\PY{p}{)}
    \PY{p}{\PYZcb{}}
\PY{p}{\PYZcb{}}

\PY{n}{data} \PY{o}{=} \PY{n+nf}{data.frame}\PY{p}{(}\PY{n}{investment}\PY{p}{,} \PY{n}{improvement}\PY{p}{)}
\PY{n}{data}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
Warning message in apply(a[!is.na(a)], 1, as.double):
“强制改变过程中产生了NA”
Warning message in apply(a[!is.na(a)], 1, as.double):
“强制改变过程中产生了NA”
Warning message in apply(a[!is.na(a)], 1, as.double):
“强制改变过程中产生了NA”
Warning message in apply(a[!is.na(a)], 1, as.double):
“强制改变过程中产生了NA”
Warning message in apply(a[!is.na(a)], 1, as.double):
“强制改变过程中产生了NA”
Warning message in apply(a[!is.na(a)], 1, as.double):
“强制改变过程中产生了NA”
Warning message in apply(a[!is.na(a)], 1, as.double):
“强制改变过程中产生了NA”
    \end{Verbatim}

    A data.frame: 27 × 2
\begin{tabular}{ll}
 investment & improvement\\
 <chr> & <dbl>\\
\hline
	 low  &  7.6\\
	 low  &  8.2\\
	 low  &  6.8\\
	 low  &  5.8\\
	 low  &  6.9\\
	 low  &  6.6\\
	 low  &  6.3\\
	 low  &  7.7\\
	 low  &  6.0\\
	 mid  &  6.7\\
	 mid  &  8.1\\
	 mid  &  9.4\\
	 mid  &  8.6\\
	 mid  &  7.8\\
	 mid  &  7.7\\
	 mid  &  8.9\\
	 mid  &  7.9\\
	 mid  &  8.3\\
	 mid  &  8.7\\
	 mid  &  7.1\\
	 mid  &  8.4\\
	 high &  8.5\\
	 high &  9.7\\
	 high & 10.1\\
	 high &  7.8\\
	 high &  9.6\\
	 high &  9.5\\
\end{tabular}


    
    \hypertarget{section}{%
\subsubsection{(1)}\label{section}}

\begin{figure}
\centering
\includegraphics{https://tva1.sinaimg.cn/large/008i3skNly1gr76e2inkyj31eg03y0ua.jpg}
\caption{题（1）}
\end{figure}

    首先，通过箱线图，直观感觉是有显著差异的：

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{3}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n+nf}{boxplot}\PY{p}{(}\PY{n}{improvement} \PY{o}{\PYZti{}} \PY{n}{investment}\PY{p}{,} \PY{n}{data} \PY{o}{=} \PY{n}{data}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{center}
    \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{output_5_0.png}
    \end{center}
    { \hspace*{\fill} \\}
    
    接下来建立方差分析表：

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{4}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{dfc} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n+nf}{aov}\PY{p}{(}\PY{n}{improvement} \PY{o}{\PYZti{}} \PY{n}{investment}\PY{p}{,} \PY{n}{data}\PY{o}{=}\PY{n}{data}\PY{p}{)}
\PY{n+nf}{summary}\PY{p}{(}\PY{n}{dfc}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    
    \begin{Verbatim}[commandchars=\\\{\}]
            Df Sum Sq Mean Sq F value   Pr(>F)    
investment   2  20.12   10.06   15.72 4.33e-05 ***
Residuals   24  15.36    0.64                     
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
    \end{Verbatim}

    
    检验 \(p < 0.05\)，拒绝原假设，认为在显著水平 \(\alpha=0.05\)
下过去三年科研经费投入的不同对当年生产力的提高有显著影响。

    \hypertarget{section}{%
\subsubsection{(2)}\label{section}}

\begin{figure}
\centering
\includegraphics{https://tva1.sinaimg.cn/large/008i3skNly1gr771206vtj61fo08an1e02.jpg}
\caption{题（2）}
\end{figure}

    首先为了方便，提取出几个组：

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{5}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{group\PYZus{}low}  \PY{o}{\PYZlt{}\PYZhy{}} \PY{n}{data}\PY{p}{[}\PY{n}{investment}\PY{o}{==}\PY{l+s}{\PYZdq{}}\PY{l+s}{low\PYZdq{}}\PY{p}{,}\PY{p}{]}
\PY{n}{group\PYZus{}mid}  \PY{o}{\PYZlt{}\PYZhy{}} \PY{n}{data}\PY{p}{[}\PY{n}{investment}\PY{o}{==}\PY{l+s}{\PYZdq{}}\PY{l+s}{mid\PYZdq{}}\PY{p}{,}\PY{p}{]}
\PY{n}{group\PYZus{}high} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n}{data}\PY{p}{[}\PY{n}{investment}\PY{o}{==}\PY{l+s}{\PYZdq{}}\PY{l+s}{high\PYZdq{}}\PY{p}{,}\PY{p}{]}
\end{Verbatim}
\end{tcolorbox}

    利用 \texttt{t.test} 容易获取到均值的置信区间：

\begin{quote}
ref: https://zhuanlan.zhihu.com/p/35713329
\end{quote}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{6}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n+nf}{t.test}\PY{p}{(}\PY{n}{group\PYZus{}low}\PY{o}{\PYZdl{}}\PY{n}{improvement}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    
    \begin{Verbatim}[commandchars=\\\{\}]

	One Sample t-test

data:  group\_low\$improvement
t = 25.361, df = 8, p-value = 6.261e-09
alternative hypothesis: true mean is not equal to 0
95 percent confidence interval:
 6.252390 7.503166
sample estimates:
mean of x 
 6.877778 

    \end{Verbatim}

    
    其中 \texttt{mean\ of\ x} 为均值，\texttt{confidence\ interval}
即置信区间。

为了方便，封装如下函数，用来提取这些信息：

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{7}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{mean\PYZus{}confin} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n+nf}{function}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{k+kc}{...}\PY{p}{)} \PY{p}{\PYZob{}}    \PY{c+c1}{\PYZsh{} mean and confidence interval of x by t.test}
    \PY{n}{t.res} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n+nf}{t.test}\PY{p}{(}\PY{n}{x}\PY{p}{,} \PY{k+kc}{...}\PY{p}{)}
    \PY{n}{mean\PYZus{}val} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n}{t.res}\PY{o}{\PYZdl{}}\PY{n}{estimate}\PY{p}{[[}\PY{l+s}{\PYZdq{}}\PY{l+s}{mean of x\PYZdq{}}\PY{p}{]]}
    \PY{n}{mean\PYZus{}conf.in} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n}{t.res}\PY{o}{\PYZdl{}}\PY{n}{conf.in}
    
    \PY{n}{res} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n+nf}{c}\PY{p}{(}\PY{n}{mean\PYZus{}val}\PY{p}{,} \PY{n}{mean\PYZus{}conf.in}\PY{p}{)}
    \PY{n+nf}{names}\PY{p}{(}\PY{n}{res}\PY{p}{)} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n+nf}{c}\PY{p}{(}\PY{l+s}{\PYZdq{}}\PY{l+s}{mean\PYZdq{}}\PY{p}{,} \PY{l+s}{\PYZdq{}}\PY{l+s}{conf.left\PYZdq{}}\PY{p}{,} \PY{l+s}{\PYZdq{}}\PY{l+s}{conf.right\PYZdq{}}\PY{p}{)}
    
    \PY{n}{res}  \PY{c+c1}{\PYZsh{} ret}
\PY{p}{\PYZcb{}}
\end{Verbatim}
\end{tcolorbox}

    调用上面封装的函数可以很方便地得到一个表格：

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{8}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{n}{mu} \PY{o}{\PYZlt{}\PYZhy{}} \PY{p}{(}\PY{n+nf}{function}\PY{p}{(}\PY{p}{)} \PY{p}{\PYZob{}}
    \PY{n}{L} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n+nf}{mean\PYZus{}confin}\PY{p}{(}\PY{n}{group\PYZus{}low}\PY{o}{\PYZdl{}}\PY{n}{improvement}\PY{p}{)}
    \PY{n}{M} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n+nf}{mean\PYZus{}confin}\PY{p}{(}\PY{n}{group\PYZus{}mid}\PY{o}{\PYZdl{}}\PY{n}{improvement}\PY{p}{)}
    \PY{n}{H} \PY{o}{\PYZlt{}\PYZhy{}} \PY{n+nf}{mean\PYZus{}confin}\PY{p}{(}\PY{n}{group\PYZus{}high}\PY{o}{\PYZdl{}}\PY{n}{improvement}\PY{p}{)}
    
    \PY{n+nf}{rbind}\PY{p}{(}\PY{n}{L}\PY{p}{,} \PY{n}{M}\PY{p}{,} \PY{n}{H}\PY{p}{)}
\PY{p}{\PYZcb{}}\PY{p}{)}\PY{p}{(}\PY{p}{)}
\PY{n}{mu}
\end{Verbatim}
\end{tcolorbox}

    A matrix: 3 × 3 of type dbl
\begin{tabular}{r|lll}
  & mean & conf.left & conf.right\\
\hline
	L & 6.877778 & 6.252390 &  7.503166\\
	M & 8.133333 & 7.652239 &  8.614427\\
	H & 9.200000 & 8.289951 & 10.110049\\
\end{tabular}


    
    得到三年经费投入为低、中、高情况下当年生产能力提高量的均值为：

\[
\begin{aligned}
\mu_L & =  6.877778 \\
\mu_M & =  8.133333 \\
\mu_H & =  9.2 \\
\end{aligned}
\]

各 95\% 置信区间如下：

\[
\begin{aligned}
\mu_L & \in  (6.252390, 7.503166) \\
\mu_M & \in (7.652239, 8.614427) \\
\mu_H & \in (8.289951, 10.110049) \\
\end{aligned}
\]

    当然，这里也可以手动实现计算过程，但比较麻烦：
# 分类汇总：means of improvements
grouped_means <- aggregate(improvement, by=list(investment), FUN=mean)
# 从方差分析表中提取出 MSE
mse <- anova(dfc)["Residuals", "Mean Sq"]
# 带入公式，用 qt 计算 t 分位数，得到置信区间
# ...
    要求 Bonferroni 同时置信区间，R
好像没有内置的实现，同样手写麻烦，所以考虑调用第三方包：

\begin{quote}
ref:
https://stackoverflow.com/questions/48572619/bonferroni-simultaneous-confidence-intervals-of-differences-in-means
\end{quote}

    \begin{tcolorbox}[breakable, size=fbox, boxrule=1pt, pad at break*=1mm,colback=cellbackground, colframe=cellborder]
\prompt{In}{incolor}{9}{\boxspacing}
\begin{Verbatim}[commandchars=\\\{\}]
\PY{c+c1}{\PYZsh{} install.packages(\PYZdq{}DescTools\PYZdq{})}
\PY{n+nf}{require}\PY{p}{(}\PY{n}{DescTools}\PY{p}{)}
\PY{n+nf}{PostHocTest}\PY{p}{(}\PY{n}{dfc}\PY{p}{,} \PY{n}{method} \PY{o}{=} \PY{l+s}{\PYZdq{}}\PY{l+s}{bonferroni\PYZdq{}}\PY{p}{)}
\end{Verbatim}
\end{tcolorbox}

    \begin{Verbatim}[commandchars=\\\{\}]
Loading required package: DescTools

    \end{Verbatim}

    
    \begin{Verbatim}[commandchars=\\\{\}]

  Posthoc multiple comparisons of means : Bonferroni 
    95\% family-wise confidence level

\$investment
              diff     lwr.ci      upr.ci    pval    
low-high -2.322222 -3.4074430 -1.23700140 3.5e-05 ***
mid-high -1.066667 -2.0961975 -0.03713579  0.0405 *  
mid-low   1.255556  0.3475947  2.16351644  0.0048 ** 

---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

    \end{Verbatim}

    
    得到 \(\mu_L-\mu_M\)，\(\mu_L-\mu_H\) 和 \(\mu_M-\mu_H\) 的置信度不小于
95\% 的 Bonferroni 同时置信区间：

\[
\begin{aligned}
\mu_L-\mu_M & \in (-2.16351644, -0.3475947  ) \\
\mu_L-\mu_H & \in (-3.4074430, -1.23700140) \\
\mu_M-\mu_H & \in (-2.0961975, -0.03713579) \\
\end{aligned}
\]

    从 \(\mu_L-\mu_M\)，\(\mu_L-\mu_H\) 和 \(\mu_M-\mu_H\) 的 Bonferroni
同时置信区间都位于负值区间可知，
随着三年科研经费的投入越高，当年生产能力的改善越显著。


    % Add a bibliography block to the postdoc
    
    
    
\end{document}
